/*******************************************************
> Copyright (C) 2024 ==IOT== All rights reserved.
> File Name: static.cpp
> Author: IOT
> Website:www.slq.org
> Created Time: 2024年10月21日 星期一 16时33分48秒
***************************************************/

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

static void globl_func()
{
	
}

class Base {

	int b = 10;
	
	public:
	static int a;
	
	static int get() // 静态成员函数无法访问非静态成员变量
	{
		//cout << this << endl;
		return a;
	}
	void set(int c)
	{
		a = c;
	}
	void show()
	{
		cout << "addr of a = " << &a << ", b = " << &this->b << endl;
		cout << "a = " << a << endl;
		//cout << "addr of a = " << &this->a << "," << &this->b << endl;
	}
};

int Base::a = 15;

int main(int argc,const char* argv[])
{
	Base obj;
	Base obj2;

	cout << "b = " << obj.get() << endl;
	cout << Base::get() << endl;
	
	obj.show();
	obj2.show();

	obj.set(15);
	obj2.show();

	cout << &Base::a << endl;
	cout << "class size:" << sizeof(Base) << "," << sizeof(obj) << endl; 
    return 0;
}

